<template>
    <div>
        {{id}}
            <div v-for="(j,pindex) in list">
                <van-field :label="i.label+index" v-for="(i,index) in j" v-model="value[pindex+i.key]"></van-field>
            </div>


            <van-button @click="add">+</van-button>
            <van-button @click="save" >提交</van-button>

            
    </div>
</template>

<script>
    export default {
        data() {
            return {
                list:[[{'label':'名称','key':'name'},{'label':'类型','key':'type'},{'label':'值','key':'value'}]],
                number:1,
                value:{},
                id:this.$route.query.id
            }
        },
        methods: {
        add(){
            this.list.push([{'label':'名称','key':'name'},{'label':'类型','key':'type'},{'label':'值','key':'value'}])
            this.number +=1
            console.log(this.value)
        },
        save(){
            var l=[]
            for(var i=0;i<this.number;i++){
                var name = i+'name'
                var type =  i+'type'
                var v =  i+'value'
                var dict = {'name':this.value[name],'value':this.value[v],'type':this.value[type]}
                l.push(dict)
            }
            console.log(l)
        },
        }
    }
</script>

<style scoped>

</style>